import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { NumberDepositsVO, NumberDepositsForm, NumberDepositsQuery } from '@/api/numberdeposits/numberDeposits/types';

/**
 * 查询会员充值管理列表
 * @param query
 * @returns {*}
 */

export const listNumberDeposits = (query?: NumberDepositsQuery): AxiosPromise<NumberDepositsVO[]> => {
  return request({
    url: '/numberDeposits/numberDeposits/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询会员充值管理详细
 * @param num
 */
export const getNumberDeposits = (num: string | number): AxiosPromise<NumberDepositsVO> => {
  return request({
    url: '/numberDeposits/numberDeposits/' + num,
    method: 'get'
  });
};

/**
 * 新增会员充值管理
 * @param data
 */
export const addNumberDeposits = (data: NumberDepositsForm) => {
  return request({
    url: '/numberDeposits/numberDeposits',
    method: 'post',
    data: data
  });
};

/**
 * 修改会员充值管理
 * @param data
 */
export const updateNumberDeposits = (data: NumberDepositsForm) => {
  return request({
    url: '/numberDeposits/numberDeposits',
    method: 'put',
    data: data
  });
};

/**
 * 删除会员充值管理
 * @param num
 */
export const delNumberDeposits = (num: string | number | Array<string | number>) => {
  return request({
    url: '/numberDeposits/numberDeposits/' + num,
    method: 'delete'
  });
};


/**
 * 根据ID列表导出会员充值
 * @param nums 需要导出的会员充值列表
 */
export const exportSelectedDeposits = (nums: Array<string | number>): AxiosPromise<Blob> => {
  return request({
    url: '/numberDeposits/numberDeposits/exportSelected',
    method: 'post',
    data: nums,
    headers: {
      'Content-Type': 'application/json'
    },
    responseType: 'blob' // 确保响应类型为blob，以便处理文件下载
  });
};


/**
 * 清空表数据
 * 
 */
export const clearNumberDeposits = () => {
  return request({
    url: '/numberDeposits/numberDeposits/clear',
    method: 'delete'
  });
};
